package com.xuanyuanxinyu.compose.ui.common

import androidx.compose.foundation.Image
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.AccountCircle
import androidx.compose.material3.Icon
import androidx.compose.material3.Scaffold
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import com.xuanyuanxinyu.compose.R
import com.xuanyuanxinyu.compose.theme.CustomerTheme
import com.xuanyuanxinyu.compose.ui.entity.Message

/**
 * @FileName:
 * @Description:
 * @author ken.luo
 * @date 2023/4/4
 * @version V1.0
 * @email 424533553@qq.com
 */

@Preview(showBackground = true)
@Composable
fun PreviewActivityUI() {
    CustomerTheme {
        Scaffold(modifier = Modifier.fillMaxSize()) { innerPadding ->
            ActivityUI(modifier = Modifier.padding(innerPadding))
        }
    }
}


@Composable
fun ActivityUI(modifier: Modifier) {
    // 行，水平布局
    Column(modifier = modifier) {
        Row(
            verticalAlignment = Alignment.CenterVertically,
            horizontalArrangement = Arrangement.End
        ) {
            // 可以设置权重
            Icon(
                Icons.Filled.AccountCircle,
                contentDescription = "Check mark",
                Modifier.weight(2f)
            )
            Image(
                // 图片放在 mipmap中可能不显示图片
                painter = painterResource(R.drawable.image),
                contentDescription = "图片",
                Modifier.weight(2f)
            )

        }

        Spacer(modifier = Modifier.height(16.dp))
        Text("MessageCard展示")
        MessageCard(
            msg = Message("Lexi", "Hey, take a look at Jetpack Compose, it's great!", false)
        )

        Row {
            Text("Column与Row\n")

            Text("的效果演示")
        }
        Column {
            Text("Box效果展示")
            Text("3 minutes ago9999")
        }
    }
}
